package com.cx330;

public class Example20 {
    public static void main(String[] args) {
        printTriangle(5);
    }

    public static void printTriangle(int n) {
        for (int i = 1; i <= n; i++) {
            // 打印前导空格
            for (int j = 1; j <= n - i; j++) {
                System.out.print(" ");
            }
            // 打印*
            for (int k = 1; k <= 2 * i - 1; k++) {
                System.out.print("*");
            }
            // 换行
            System.out.println();
        }
    }
}
